import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int a = scanner.nextInt(); //起始楼层
        int b = scanner.nextInt(); //终止楼层

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        //dp[i][j] 表示i楼层是否可以到达j楼层，若可以到达，就为1，反之为0
        //多加一行和一列，将dp的下标与楼层相对应
        int[][] dp = new int[n + 1][n + 1];
        for (int i = 1; i < n + 1; i++) {
            int index = i - 1;
            if (i + arr[index] <= n) {
                dp[i][i + arr[index]] = 1;
            }
            if (i - arr[index] > 0) {
                dp[i][i - arr[index]] = 1;
            }
        }

        Queue<Integer> queue = new LinkedList<>();

        boolean[][] flag = new boolean[n + 1][n + 1];

        queue.offer(a);

        int count = 0;
        while (!queue.isEmpty()) {
            int size = queue.size();
            count++;
            while (size > 0) {
                size--;
                int index = queue.poll();
                for (int j = 1; j < n + 1; j++) {
                    if (dp[index][j] == 1 && !flag[index][j]) {
                        queue.offer(j);
                        flag[index][j] = true;
                        if (j == b) {
                            System.out.println(count);
                            return;
                        }
                    }
                }
            }
        }

        System.out.print(-1);

//        for (int i = 1; i < n + 1; i++) {
//            for (int j = 1; j < n + 1; j++) {
//                System.out.print(dp[i][j] + " ");
//            }
//            System.out.println();
//        }

        scanner.close();
    }
}
